import 'package:flutter/material.dart';

/// 数据Provider，如果要传多个数据可以用Map(key:value)
class DataProvider extends InheritedWidget {
  final Map<String, dynamic> data;

  DataProvider({Key key, @required Widget child, this.data})
      : super(key: key, child: child);

  @override
  bool updateShouldNotify(DataProvider oldWidget) {
    return data != oldWidget.data;
  }

  static Map<String, Object> of(BuildContext context) {
    return context.dependOnInheritedWidgetOfExactType<DataProvider>().data;
  }
}
